<?php

/*
 * This file is part of Sulu.
 *
 * (c) Sulu GmbH
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sulu\CustomUrl\Domain\Event;

use Sulu\Bundle\ActivityBundle\Domain\Event\DomainEvent;
use Sulu\CustomUrl\Domain\Model\CustomUrl;
use Sulu\CustomUrl\Domain\Model\CustomUrlInterface;
use Sulu\CustomUrl\Infrastructure\Sulu\Admin\CustomUrlAdmin;

class CustomUrlRestoredEvent extends DomainEvent
{
    /**
     * @param mixed[] $payload
     */
    public function __construct(
        private CustomUrlInterface $customUrl,
        private array $payload
    ) {
        parent::__construct();
    }

    public function getCustomUrl(): CustomUrlInterface
    {
        return $this->customUrl;
    }

    public function getEventType(): string
    {
        return 'restored';
    }

    public function getEventPayload(): ?array
    {
        return $this->payload;
    }

    public function getResourceKey(): string
    {
        return CustomUrl::RESOURCE_KEY;
    }

    public function getResourceId(): string
    {
        return $this->customUrl->getUuid();
    }

    public function getResourceWebspaceKey(): ?string
    {
        return $this->customUrl->getWebspace();
    }

    public function getResourceTitle(): ?string
    {
        return $this->customUrl->getTitle();
    }

    public function getResourceSecurityContext(): ?string
    {
        return CustomUrlAdmin::getCustomUrlSecurityContext($this->customUrl->getWebspace());
    }
}
